﻿
@using QDT.Core
@using QDT.Core.Projects
@using QDT.Web
@using QDT.Web.Code
@model QDT.Core.Projects.Project
@{
    Layout = null;
    Layout = "~/Views/Shared/_Layout2.cshtml";
}
           
<link rel="stylesheet" type="text/css" href="/Content/Default/CSS/style.css" />
<div id="jm-touch" class="app-link-displaying">
<div class="profit">
    @if (Model.Status == ProjectStatus.Progress)
    {

        var userAccount = Html.F().GetUserAccount(QDTContext.Current.User.UserAccountID);

        <div id="bid_wait" class="@(Model.StartTime.Value < DateTime.Now ? "hide" : "")"  style="text-align: center;line-height: 32px;">
            <div style="margin-top: 40px;">
                <span>待售中...</span>
                <div>
                    <span>可投金额：<span style="color: #f39c12; font-size: 16px;">@Model.NeedMoney.ToMoney()</span>元</span><br/>
                    <span>@Model.StartTime.Value.ToString("MM-dd HH:mm") 开始售出</span><br/>
                </div>
                <div>
                    即将开始
                </div>
            </div>
        </div>

    
        <div id="bid_form" class="@(Model.StartTime.Value > DateTime.Now ? "hide" : "")" style="text-align: center;line-height: 32px;">
       
            <div style="margin-top: 40px;">
                <span>立即投资</span>
                <div>
                    <span>已发时间: @((DateTime.Now - Model.StartTime.Value).Hours) 小时 @((DateTime.Now - Model.StartTime.Value).Minutes) 分</span><br/>
                    <span>可投金额：<span style="color: #f39c12; font-size: 16px;">@Model.NeedMoney.ToMoney()</span>元</span><br/>
               
                </div>
                            
                <form action="@Url.Action("Bid")" method="POST">
                    <div>
                        <input type="hidden" name="ID" value="@Model.ID"/>
                        <input type="hidden" name="safePassword" value=""/>
                        <input id="bid-money" name="money"type="text" style="border-top: 1px solid #eee;height: 25px;"/>
                    </div>
                    <div>
                        <span style="font-size: 14px; padding-left: 15px;">可用余额：@userAccount.Money.ToMoney() 元</span>
                    </div>
              
                    <button class="button" id="bid-submit" type="submit" style="font: 16px/1.5 'Microsoft Yahei', 'Simsun';border: none;width: 30%;color: #fff;background: #E74C3C;height: 32px;">确认投资</button><br/>
            
                </form>
            </div>
        </div>

    }
    else
    {
        <div id="bid_form" style="text-align: center;line-height: 32px;">
      
            <div style="margin-top: 80px;">
                <span style="font-size: 20px;">项目已满或无可投项目</span>
            </div>
        </div>
    }
    
              
    <div style="text-align: center;margin-top: 40px;">乾贷网提醒您：投资有风险</div>
                
          
</div>


    <div class="invest-btn-c" style="position: fixed;width: 100%;bottom: 0;left: 0;background-color: #f6f6f6;height: 50px;">
        <a href="@Url.Action("ProjectDetail", "Home", new { id = Model.ID })" style="display: block;background-color: #E74C3C;text-align: center;color: #fff;height: 50px;line-height: 50px;margin: 0 0;">查看详情</a>
    </div>

</div>
<script type="text/javascript">

 $("#bid-submit").click(function() {
        var m = $("#bid-money").val();
        if (m == null || m==0) {
            alert("请输入正确的投资金额");
            return false;
        } else {
            return confirm("确定投资" + m + "元?");
        }
    });

    $(".p-nav-tab").click(function() {
        $(".p-nav-tab").removeClass("active");
        $(this).addClass("active");
        var nav = $(this).attr('data-nav');
        $(".nav").addClass("hide");
        $("#" + nav).removeClass("hide");
    });

    $("document").ready(function() {
        var process = 6;
        @if (Model.Status == ProjectStatus.Full)
        {
            <text>process = 7;</text>
        }else if (Model.Status == ProjectStatus.Repaying || Model.Status == ProjectStatus.Repaid)
        {
            <text>process = 8;</text>
        }
        $("#process-" + process).addClass("p-active");
        $(".p-process-point").addClass("p-process-point" + process);
    });

    $('#more_bid_list').click(function() {
        $("#project_bid_list").load("/Project/AllBidList?ProjectId=" + @Model.ID);
    });

   

    @if (Model.StartTime.Value > DateTime.Now)
    {
        <text>
            $().ready(function () {
                var year = @Model.StartTime.Value.Year;
                var month = @Model.StartTime.Value.AddMonths(-1).Month;
                var day = @Model.StartTime.Value.Day;
                var hour = @Model.StartTime.Value.Hour;
                var minute = @Model.StartTime.Value.Minute;
                var start = new Date(year,month,day,hour,minute,0);
                setInterval(function () {
                    var now = new Date();
                    if (start < now) {
                        $('#bid_form').removeClass('hide');
                        $('#bid_wait').addClass('hide');
                    }
                }, 1000);
            });
        </text>
    }

</script>